<?php

namespace App\Http\Controllers\Home;

use App\Models\Config;
use App\Models\Friend;
use App\Http\Controllers\Controller;
use App\Models\Menu;

class BaseController extends Controller
{

    public $theme;
    public $view;

    public function __construct()
    {
        parent::__construct();
        #todo 缓存
        $configs = Config::all();
        foreach ($configs as $config){
            config([$config->name=>$config->value]);
        }
        $this->theme = 'themeName';
        $this->view = 'theme/' . $this->theme.'/';
        view()->share('assets', "/theme/$this->theme");
        view()->share('view', $this->view.'/');
        view()->share('imgHost', env('QINIU_HOST'));
    }
    protected  function navMenu($menuId){
        $menu = Menu::findOrFail($menuId);
        //导航模块
        $navMenu=$menu;
        while ($navMenu->type!=4){
            $navMenu=$navMenu->parent;
        }
        view()->share('menu',$menu);
        view()->share('navMenu',$navMenu);
        return $menu;
    }
}
